/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

function loadPlan() {
    Ext.Ajax.request({
        url:'plan.do?action=loadPlan',
        method:'post',
        params:{
            planid : planid
        },

        success:function(response){
//alert(response.responseText);
            var responseArray = eval(" ("+ response.responseText + ")");
            
            var eventInfo;
            for(var i=0; i<responseArray.events.length; i++){
                eventInfo = new EventInfo("original", responseArray.events[i]);
                eventInfoArray.push(eventInfo);
            }
            plan = new Plan(responseArray.planid, responseArray.planname,
                                responseArray.plandescript, eventInfoArray);
            Ext.get("planname").dom.value = plan.planname;
            Ext.get("plandescription").dom.innerHTML = plan.plandescript;
            displayEvents();
//alert(JSON.stringify(plan));
        },

        failure:function(action){
            alert('failed');
            Ext.Msg.alert('Error', 'Reason\uff1a' + action.result.errors.info);
        }
    });
}
